package com.thirtydays.frame.ui.pop

import android.content.Context
import com.lxj.xpopup.core.CenterPopupView
import com.thirtydays.frame.R
import com.thirtydays.frame.databinding.UploadPopViewBinding
import com.thirtydays.frame.util.ext.clicks
import com.thirtydays.frame.util.ext.gone
import com.thirtydays.frame.util.ext.visible

/**
 * @author 小垚
 * @创建时间： 2021/6/1
 * @描述： 更新弹窗
 **/
class UploadPopView(context: Context, isForce: Boolean, desc: String, onUpload: (UploadPopView) -> Unit) : CenterPopupView(context) {
    override fun getImplLayoutId() = R.layout.upload_pop_view

    lateinit var viewBinding: UploadPopViewBinding
    private var mDesc = desc
    private var mOnUpload = onUpload
    private var mIsForce = isForce

    override fun onCreate() {
        super.onCreate()
        viewBinding = UploadPopViewBinding.bind((contentView))

        viewBinding.tvDesc.text = mDesc

        if (mIsForce) {
            viewBinding.tvCancel.visible()
            viewBinding.vhLine.visible()
        } else {
            viewBinding.tvCancel.gone()
            viewBinding.vhLine.gone()
        }

        viewBinding.tvCancel.clicks {
            dismiss()
        }

        viewBinding.tvUpdate.clicks {
            mOnUpload(this)
        }
    }
}